import { ADDPERSON, DELETEPERSON } from "../constant";

let initPerson = [{id:1,name:"豆奶",age:18,}]

export default function count(preState=initPerson, action) {
    const { type, data } = action
    switch (type) {
        case ADDPERSON:
            return [data,...preState]
        case DELETEPERSON:
            let arr = preState.filter(item => item.id !== data)
            return arr
        default:
            return preState
    }
}